
#include "LightMatch.hpp"
#include "Function.hpp"
#include<string>
int main(int argc, char *argv[])
{
    //read video
    cv::VideoCapture cap;
    std::string xl="/home/lenovo/_gitee/code_files/tasks/Judge/video";
    std::string xr=".avi";
    std::string x;
    while (true)
    {
        std::cin >> x;
        x=xl+x+xr;
        std::string path = x;
        cap.open(path);
        if (cap.isOpened() == false)
        {
            std::cerr << "Failed to load video from '" << path << "'\n";
            return -1;
        }
        //start to match light
        cv::Mat frame;
        //cv::namedWindow("disp", cv::WINDOW_AUTOSIZE);
        int frame_cnt = 0;
        Function F;
        while (true)
        {
            if (cv::waitKey(1) == 'q')
                break;
            std::cout << "Frame " << frame_cnt++ << " started " << std::endl;
            cap.read(frame); //取帧
            F.findlight(frame);
            cv::imshow("test", frame);
            cv::waitKey(10);
        }
        cv::destroyAllWindows();
        cap.release();
    }
    return 0;
}